package com.tx.logsys.config;

import com.tx.logsys.interceptor.TimeCostInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * web config
 *
 * @author
 */
@Configuration
public class WebConfigurer implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 配置拦截器
        registry.addInterceptor(timeCostInterceptor()).addPathPatterns("/**");
    }

    /**
     * 请求日志拦截
     * 处理跨域
     * @return
     */
    @Bean
    public TimeCostInterceptor timeCostInterceptor() {
        return new TimeCostInterceptor();
    }

}